<!DOCTYPE html>
<html xmlns="">

	<head>
		<meta charset="UTF-8">
		<title></title>
		</style>
	</head>

	<body>
	<div class="container">
		<h1>请注册</h1>
		<form>
			<label id="biaoq">用户名</label>
			<div class="form-control">
				<input type="text" required placeholder="Username" id="nameId">
			</div>
			<label>密码</label>
			<div class="form-control">
				<input type="password" required placeholder="Password" id="passId">
			</div>
			<label>确认密码</label>
			<div class="form-control">
				<input type="password" required placeholder="Confirm password" id="conId">
			</div>
			<label>性别</label>
			<br>
			<br>
			<label>
				<input type="radio" id="sexnanId" value="男" name="sex"/>男
				<input type="radio" id="sexnvId" value="女" name="sex"/>女</label>
			<br>
			<br>
			<label>电话</label>
			<div class="form-control">
				<input type="text" required placeholder="Telephone" id="telId">
			</div>
			<label>邮箱</label>
			<div class="form-control">
				<input type="text" required placeholder="Email" id="emailId">
			</div>
			<button id="btn-reg" type="reset">注册</button>
		</form>

	</div>
	</body>
<script src="dist/js/jquery.min.js"></script>
<script>
	// <!-- 获取立即注册按钮并绑定点击事件-->
	$("#btn-reg").click(function (){
		console.log($("#nameId").val())
		console.log($("#passId").val())
		console.log($("#conId").val())
		console.log($("input[name='sex']:checked").val())
		console.log($("#telId").val())
		console.log($("#emailId").val())
		if($("#nameId").val() == "" || $("#passId").val() == "" || $("#conId").val() == "" || $("#sexId").val() == "" || $("#telId").val() == "" || $("#emailId").val() == ""){
			alert("请输入完整的信息注册")
		}else if($("#passId").val() != $("#conId").val()){
			alert("请输入正确的确认密码")
		}else{
			// 发送ajax请求到服务端进行注册
			$.ajax({
				url: "http://192.168.96.109:8060/user/reg", //请求地址
				type: "POST", //请求方法
				data: {  //请求传递的参数
					username: $("#nameId").val(),
					password: $("#passId").val(),
					sex:$("input[name='sex']:checked").val(),
					telephone: $("#telId").val(),
					eMail: $("#emailId").val(),
				},
				dataType: "json", //返回类型
				success: function (res){ //请求成功调函数
					console.log(res)
					if(res.state ==200){
						alert("注册成功")
					}else{
						alert(res.message)
					}
				}
			})
		}
	})
</script>

</html>
